package com.qqt.csr.archive.batch.task.exception;

import lombok.NonNull;
import lombok.extern.slf4j.Slf4j;
import org.springframework.batch.repeat.RepeatContext;
import org.springframework.batch.repeat.exception.ExceptionHandler;
import org.springframework.stereotype.Component;

/**
 * @Author: yang hao
 * @Date: 2024/12/2 14:15
 * @Description: 批处理异常处理
 **/
@Slf4j
@Component
public class ArchiveTaskExceptionHandler implements ExceptionHandler {

    /**
     * 处理异常
     * @param context {@link RepeatContext} 批处理上下文
     * @param throwable {@link Throwable} 异常
     */
    @Override
    public void handleException(@NonNull RepeatContext context, @NonNull Throwable throwable) throws Throwable {
        log.error("批处理任务发生异常,上下文:{},异常:{}", context, throwable.getMessage(), throwable);
        throw throwable;
    }

}
